﻿using System.IO;
using System.Reflection;


namespace LockerRack.Helpers
{
    public class PathUtility
    {
        public static string GetAppPath()
        {
            return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        }

        public static bool CheckDirectories(string filename)
        {
            if(string.IsNullOrEmpty(filename))
                return false;

            var dir = Path.GetDirectoryName(filename);
            return CheckDirectory(dir);
        }

        public static bool CheckDirectory(string path)
        {
            if (string.IsNullOrEmpty(path))
                return false;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            return true;
        }
    }
}
